package com.xiaoshuidi.cloud.module.report.controller.ajreport;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.report.controller.ajreport.vo.ReportRoomReverseReqVO;
import com.xiaoshuidi.cloud.module.report.controller.ajreport.vo.ReportSalesControlReqVO;
import com.xiaoshuidi.cloud.module.report.controller.ajreport.vo.ReportSalesControlRespVO;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.ExportRespVO;
import com.xiaoshuidi.cloud.module.report.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.report.service.ajreport.ReportSalesControlService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Slf4j
@Tag(name = "报表 - 销控表")
@RestController
@RequestMapping(ApiConstants.PREFIX+"/sales")
public class ReportSalesControlController {


    @Resource
    private ReportSalesControlService reportSalesControlService;

    @PostMapping("/salesControlPage")
    @Operation(summary = "销控表分页查询")
    public CommonResult<PageResult<ReportSalesControlRespVO>> salesControlPage(@RequestBody @Valid ReportSalesControlReqVO reqVO) {
        log.info("salesControlPage req:{}",reqVO.toString());
        PageResult<ReportSalesControlRespVO> pageResult = reportSalesControlService.salesControlPage(reqVO);
        return success(pageResult);
    }

    /**
     * 预定台账导出
     *
     * @return
     */
    @PostMapping("/salesControlExport")
    @Operation(summary = "销控表导出")
    public CommonResult<ExportRespVO> roomReverseExprot(@RequestBody @Valid ReportSalesControlReqVO req) {
        log.info("salesControlExport req:{}",req.toString());
        return CommonResult.success(reportSalesControlService.salesControlExport(req));
    }

}
